Page({
  data: {
    home: false
  },
  addlike: function (res) {
    qq.saveAppToDesktop({
      success(res) {
        qq.showToast({
          title: '成功',
          icon: 'success',
          duration: 2000
        })
      },fail(res){
         qq.showToast({
          title: '貌似不成功',
          icon: 'none',
          duration: 2000
        })
      }
    })
  },
  switchHome: function (res) {
    console.log(res.detail.value)
    try {
      qq.setStorageSync('home', res.detail.value)
    } catch (e) { }
  },
  clearall: function () {

    qq.showModal({
      title: '提示',
      content: '清除数据后需重新绑定学号~',
      success(res) {
        if (res.confirm) {
          try {
            qq.clearStorageSync()
            qq.showToast({
              title: '成功',
              icon: 'success',
              duration: 2000
            })
            qq.reLaunch({
              url: "/pages/core/set/set"
            })
          } catch (e) {
            qq.showToast({
              title: '失败',
              icon: 'none',
              duration: 2000
            })
          }
        } else if (res.cancel) {
          qq.showToast({
            title: '取消清除',
            icon: 'success',
            duration: 2000
          })
        }
      }
    })


  },
  onLoad: function () {
    const that = this
    qq.getStorage({
      key: 'home',
      success(res) {
        that.setData({
          home: res.data
        })
        console.log('huoqu', res.data)
      }
    })
  }
})